/**
 * 版本信息管理
 * @author xiaoxujs
 */

import { useCallback, useEffect, useState } from "react";
import { UlBox, VersionInfomationPageBox, VersionInfomationPageHeaderBox } from "./style";
import { postSyhtDictTelemetryGetAssistTelemetryList } from "../../../api/VersionInfomation";
import { INoFenye } from "../../../type/common";
import { ISyhtDictTelemetryGetAssistTelemetryList } from "../../../type/VersionInfomation/api";
import { message } from "antd";

const VersionInfomationPage = () => {
    const [messageApi, contextHolder] = message.useMessage();
    const [listData, setListData] = useState([]); // 列表数据
    const listFun = useCallback(
        async () => {
            const { code, msg, data } = await postSyhtDictTelemetryGetAssistTelemetryList() as INoFenye<ISyhtDictTelemetryGetAssistTelemetryList>;
            if (code === 200) {
                setListData(JSON.parse(JSON.stringify(data)))
            } else {
                messageApi.error(msg)
            }
        }, [messageApi]
    )
    useEffect(() => {
        listFun()
    }, [listFun])
    return <VersionInfomationPageBox>
        <VersionInfomationPageHeaderBox>
            <div>版本信息 </div>
        </VersionInfomationPageHeaderBox>
        <UlBox>
       
            {
                listData.map((item: ISyhtDictTelemetryGetAssistTelemetryList, index: number) => {
                    return <li key={index}>
                        <div className="title">{item.paramName}</div>
                    <div className="value">{item.value ? item.value : '- -'}</div>
                    </li>
                })
            }
        </UlBox>
        {contextHolder}
    </VersionInfomationPageBox>;
}

export default VersionInfomationPage;